package com.whcoding.test.example.restTemplate;

import java.io.Serializable;

public class ResultApiUtil<T extends Serializable> implements Serializable {

    private boolean success;
    private String code;
    private String message;
    private T data;

    public static <T extends Serializable> ResultApiUtil<T> success(String code, String message, T data) {
        ResultApiUtil<T> result = new ResultApiUtil<>();
        result.code = code;
        result.message = message;
        result.data = data;
        result.success = true;
        return result;
    }

    public static <T extends Serializable> ResultApiUtil<T> success(T data) {
        return success("200", "成功", data);
    }

    public static <T extends Serializable> ResultApiUtil<T> fail(String code, String message) {
        ResultApiUtil<T> result = new ResultApiUtil<>();
        result.code = code;
        result.message = message;
        result.success = false;
        return result;
    }

}
